package com.hhsj.dynamicui.model;


import com.google.gson.annotations.SerializedName;
import com.hhsj.dynamicui.model.base.JSONAble;

import org.json.JSONObject;

import java.io.Serializable;

/**
 * widgetType : BANNER
 * desc : 这是轮播图组件
 * backgroud : #00000000
 * marginLeft : 0
 * marginTop : 0
 * marginRight : 0
 * marginBottom : 0
 * businessType: "业务"
 * businessParams : #{widgetType,data},{1,2}
 */
//一个业务模块
public final class ModuleBean implements Serializable, JSONAble {

    @SerializedName("widget_layout_id")
    private String widgetId;//当前业务视图id

    @SerializedName("rank_no")
    private int rankNo;//排序

    @SerializedName("group_id")
    private String groupId;//组id

    @SerializedName("widget_code")
    private String widgetType;//指定特定控件

    @SerializedName("widget_spec")
    private String widgetSpec;//特定属性，Config json，控制widget的特有属性

    @SerializedName("business_code")
    private String businessType;//业务类型，控制数据模型

    @SerializedName("business_params")
    private String businessParams;//控制业务数据请求

    @SerializedName("child_widget_code")
    private String childWidgetType;//子视图类型

    @SerializedName("child_property")
    private ViewBean childProperty;//视图基本属性属性

    @SerializedName("widget_desc")
    private String desc;//描述

    private ViewBean property;//视图基本属性属性

    public ViewBean getChildProperty() {
        return childProperty;
    }

    public void setChildProperty(ViewBean childProperty) {
        this.childProperty = childProperty;
    }

    public String getChildWidgetType() {
        return childWidgetType;
    }

    public void setChildWidgetCode(String childWidgetType) {
        this.childWidgetType = childWidgetType;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getWidgetId() {
        return widgetId;
    }

    public void setWidgetId(String widgetId) {
        this.widgetId = widgetId;
    }

    public int getRankNo() {
        return rankNo;
    }

    public void setRankNo(int rankNo) {
        this.rankNo = rankNo;
    }

    public String getWidgetSpec() {
        return widgetSpec;
    }

    public void setWidgetSpec(String widgetSpec) {
        this.widgetSpec = widgetSpec;
    }

    public ViewBean getProperty() {
        return property;
    }

    public void setProperty(ViewBean property) {
        this.property = property;
    }

    public String getWidgetType() {
        return widgetType;
    }

    public void setWidgetCode(String widgetType) {
        this.widgetType = widgetType;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getBusinessType() {
        return businessType;
    }

    public void setBusinessCode(String businessType) {
        this.businessType = businessType;
    }

    public String getBusinessParams() {
        return businessParams;
    }

    public void setBusinessParams(String businessParams) {
        this.businessParams = businessParams;
    }

    @Override
    public String toJSONString() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("widget_desc", desc);
        jsonObject.put("widget_layout_id", widgetId);
        jsonObject.put("rank_no", rankNo);
        jsonObject.put("group_id", groupId);
        jsonObject.put("widget_code", widgetType);
        jsonObject.put("widget_spec", widgetSpec);
        jsonObject.put("business_code", businessType);
        jsonObject.put("business_params", businessParams);
        jsonObject.put("child_widget_code", childWidgetType);
        if (childProperty != null) {
            jsonObject.put("child_property", new JSONObject(childProperty.toJSONString()));
        }
        if (property != null) {
            jsonObject.put("property", new JSONObject(property.toJSONString()));
        }
        return jsonObject.toString();
    }
}